<?php 
	include_once 'dataservice.php';
	include_once 'thuvienham.php';

	class nguoidungloai_db 
	{
		public function Them($MaLoaiNguoiDung, $TenLoaiNguoiDung, $ChuThich)
		{
			$sql = "INSERT INTO `tbl_nguoidungloai`(`MaLoaiNguoiDung`, `TenLoaiNguoiDung`, `ChuThich`)
					VALUES ('$MaLoaiNguoiDung', '$TenLoaiNguoiDung', '$ChuThich')";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function Xoa($MaLoaiNguoiDung)
		{
			$sql = "DELETE FROM `tbl_nguoidungloai` WHERE `MaLoaiNguoiDung` = '$MaLoaiNguoiDung'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function CapNhat($MaLoaiNguoiDung, $TenLoaiNguoiDung, $ChuThich)
		{
			$sql = "UPDATE `tbl_nguoidungloai`
					SET `TenLoaiNguoiDung` = '$TenLoaiNguoiDung', `ChuThich` = '$ChuThich'
					WHERE `MaLoaiNguoiDung` = '$MaLoaiNguoiDung'";

			$service = new dataservice();
			return $service->ExecuteNonQuery($sql);
		}

		public function LayDanhSach($MaLoaiNguoiDung, $TenLoaiNguoiDung, $ChuThich)
		{
			$sql = "SELECT * FROM `tbl_nguoidungloai` WHERE 1  ";
			if($MaLoaiNguoiDung != "")
				$sql .= " AND `MaLoaiNguoiDung` = '$MaLoaiNguoiDung' ";

			if($TenLoaiNguoiDung != "")
				$sql .= " AND `TenLoaiNguoiDung` = '$TenLoaiNguoiDung' ";

			if($ChuThich != "")
				$sql .= " AND `ChuThich` = '$ChuThich' ";

			$service = new dataservice();
			return $service->ExecuteQuery($sql);
		}

	}

